import matplotlib.pyplot as plt

x = [0, 1, 2, 3, 4, 5]
y1 = [2 * y for y in x]
y2 = [y**2 for y in x]

plt.plot(x, y1, marker="o", label="2*x")
plt.plot(x, y2, marker="s", label="x^2")

# 1.显示各数据名称
plt.legend()

# 2.标注每个数据点
for i, (a, b) in enumerate(zip(x, y1)):
    plt.text(a, b + 1, f"{b}", ha="center")
for i, (a, b) in enumerate(zip(x, y2)):
    plt.text(a, b + 1, f"{b}", ha="center")

plt.show()
